<template>
  <transition name="fade">
    <div class="notify" :style="style" v-show="visible">
      <div class="notify-content">
        {{ content }}
      </div>
      <div class="close" @click="close">{{closeText}}</div>
    </div>
  </transition>  
</template>

<script>
  export default {
    name: 'notify',
    props: {
      content: {
        type: String,
        required: true
      },
      closeText: {
        type: String,
        default: '关闭'
      }
    },
    data() {
      return {
        visible: true
      }
    },
    computed: {
      style() {
        return {}
      }
    },
    methods: {
      close(e) {
        e.preventDefault()
        this.$emit('close')
      }
    }
  }
</script>

<style scoped>
.notify {
  display: flex;
  min-width: 200px;
  max-width: 300px;
  background: rgba(0,0,0,0.5);
  padding: 10px;
  color: rgba(255,255,255,.8);
  box-shadow: 0px 3px 5px -1px rgba(0, 0, 0, 0.2), 0px 6px 10px 0px rgba(0, 0, 0, 0.14), 0px 1px 18px 0px rgba(0, 0, 0, 0.12);
}
.notify-content {
  flex: 1;
  padding-right: 10px;
}
.close {
  padding: 0 5px;
  font-size: 12px;
  cursor: pointer;
}
.close:hover {
  color: #fff;
}
</style>